package com.blueocean_health.care.management.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.blueocean_health.care.management.domain.base.SysResult;
import com.blueocean_health.care.management.service.PowerService;

/**
* @author huyanqiu
* @date 2018年3月23日 下午2:27:44
* @version 版本号：1.0
*/
@RestController
@RequestMapping("/power")
public class PowerController {
	
	@Autowired
	private PowerService powerService;
	
	/**
	 * 获得对应组织的权限清单
	 * @return
	 */
	@RequestMapping("/list")
	public SysResult list(@RequestBody String jsonString) {
		JSONObject jsonObject = JSONObject.parseObject(jsonString);
		String orgId = "";
		int type = 0;
		try{
			orgId =jsonObject.getString("orgId");
			type = jsonObject.getIntValue("type");
		} catch (NumberFormatException e) {
			return SysResult.error("参数异常");
		}
		if (type!=1 && type!=2) {
			return SysResult.error("参数异常");
		}
		return powerService.list(orgId, type);
	}
	
}
